// Copyright (c) 2019 Presto Labs Pte. Ltd.
// Author: donggu

#include "coin2/base/time.h"

#include <gtest/gtest.h>

TEST(Base, Time) {
  EXPECT_EQ(TimestampFromDatetime(2019, 2, 3), 1549152000'000000000);
  EXPECT_EQ(TimestampFromDatetime(2065, 11, 1, 5, 1, 17), 3024277277'000000000);

  auto time = PtimeFromTimestamp(1549152000'000000000ll);
  EXPECT_EQ(time.date().year(), 2019);
  EXPECT_EQ(time.date().month(), 2);
  EXPECT_EQ(time.date().day(), 3);
  EXPECT_EQ(time.time_of_day().hours(), 0);

  time = PtimeFromTimestamp(3024277277'000000000ll);
  EXPECT_EQ(time.date().year(), 2065);
  EXPECT_EQ(time.date().month(), 11);
  EXPECT_EQ(time.date().day(), 1);
  EXPECT_EQ(time.time_of_day().hours(), 5);
}
